home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Web Browse262539102001.psc / HtmlParsing.bas < prev    next >
Encoding:
BASIC Source File  |  2001-08-18  |  2.0 KB  |  70 lines

  1. Attribute VB_Name = "html"
  2. 'cut scripts out of html,
  3. 'removes script blocks and
  4. 'breaks all inline scripting
  5. 'these are kinda old coding so milage will vary..time for
  6. 'light overhaul
  7.  
  8. 'Author: dzzie@yahoo.com
  9.  
  10. Public Function parseScript(info)
  11.   Dim EndOfScript As Integer, scripData As String, trimPage As String
  12.   info = filt(info, "javascript,vbscript,mocha,createobject,activex")
  13.   Script = Split(info, "<script")
  14.   If UBound(Script) = 0 Then parseScript = info: Exit Function _
  15.   Else: trimPage = Script(0)
  16.   For i = 1 To UBound(Script)
  17.     EndOfScript = InStr(1, Script(i), "</script>")
  18.     trimPage = trimPage & Mid(Script(i), EndOfScript + 10, Len(Script(i)))
  19.   Next
  20.   parseScript = trimPage
  21. End Function
  22.  
  23.  
  24. 'remove all html tags (can be buggered if html
  25. 'tag contains quoted > or <
  26. Public Function parseHtml(info) As String
  27.      Dim temp As String, EndOfTag As Integer
  28.      fmat = Replace(info, " ", " ")
  29.      cut = Split(fmat, "<")
  30.  
  31.    For i = 0 To UBound(cut)  'cut at all html start tags
  32.      EndOfTag = InStr(1, cut(i), ">")
  33.         If EndOfTag > 0 Then
  34.           EndOfText = Len(cut(i))
  35.           NL = False
  36.           If Left(cut(i), 2) = "br" Then NL = True
  37.           cut(i) = Mid(cut(i), EndOfTag + 1, EndOfText)
  38.           If NL Then cut(i) = vbCrLf & cut(i)
  39.           If cut(i) = vbCrLf Then cut(i) = ""
  40.         End If
  41.      temp = temp & cut(i)
  42.     Next
  43.     
  44.     parseHtml = temp
  45. End Function
  46.  
  47. 'trims out & type html for text
  48. Public Function parseAnds(info)
  49.   Dim temp As String
  50.   cut = Split(info, "&")
  51.   If UBound(cut) > 0 Then
  52.     For i = 0 To UBound(cut)            'cut at all start tags (&)
  53.       EndOfTag = InStr(1, cut(i), ";")
  54.         If EndOfTag > 0 Then
  55.            EndOfText = Len(cut(i))
  56.            cut(i) = Mid(cut(i), EndOfTag + 1, EndOfText)
  57.         End If
  58.       temp = temp & cut(i)
  59.     Next
  60.    parseAnds = temp
  61.   Else: parseAnds = info
  62.   End If
  63. End Function
  64.  
  65. Function ParseAll(it) As String
  66.     't = parseAnds(it)
  67.     't = parseScript(t)
  68.     ParseAll = parseHtml(it)
  69. End Function
  70.